// 示例：如何在其他页面使用 POI 深链功能
import { useRouter } from 'next/navigation'
import { poiCatalog } from './poiCatalog'

// 示例：在科室管理页面注册科室POI
export function registerDepartmentPOIs() {
  poiCatalog.registerPOIs([
    {
      id: 'dept_cardio',
      name: '心内科',
      type: 'department',
      position: [120.1555, 30.2745],
      floor: 'L3',
      description: '心血管疾病诊疗科室'
    },
    {
      id: 'dept_emergency',
      name: '急诊科',
      type: 'emergency',
      position: [120.1545, 30.2735],
      floor: 'L1',
      description: '24小时急诊服务'
    }
  ])
}

// 示例：在设备管理页面注册设备POI
export function registerEquipmentPOIs() {
  poiCatalog.registerPOIs([
    {
      id: 'equip_mri_1',
      name: 'MRI-1号机',
      type: 'equipment',
      position: [120.1550, 30.2740],
      floor: 'L1',
      description: '磁共振成像设备 - 1号机房'
    },
    {
      id: 'equip_ct_1',
      name: 'CT-1号机',
      type: 'equipment',
      position: [120.1558, 30.2748],
      floor: 'L2',
      description: 'CT扫描设备 - 1号机房'
    }
  ])
}

// 示例：在卡片组件中使用跳转
export function useMapNavigation() {
  const router = useRouter()
  
  const navigateToMapWithPOIs = (poiIds: string[], zoom = 18) => {
    const url = `/dashboard?poiIds=${encodeURIComponent(poiIds.join(','))}&zoom=${zoom}`
    router.push(url)
  }
  
  const navigateToDepartment = (deptId: string) => {
    navigateToMapWithPOIs([deptId], 18)
  }
  
  const navigateToEquipment = (equipId: string) => {
    navigateToMapWithPOIs([equipId], 19)
  }
  
  const navigateToMultiplePOIs = (poiIds: string[]) => {
    navigateToMapWithPOIs(poiIds, 17)
  }
  
  return {
    navigateToMapWithPOIs,
    navigateToDepartment,
    navigateToEquipment,
    navigateToMultiplePOIs
  }
}

// 示例：在React组件中的具体使用
/*
export function DepartmentCard({ department }: { department: Department }) {
  const { navigateToDepartment } = useMapNavigation()
  
  const handleViewOnMap = () => {
    // 确保POI已注册
    poiCatalog.registerPOI({
      id: `dept_${department.id}`,
      name: department.name,
      type: 'department',
      position: department.coordinates, // 从你的数据中获取
      floor: department.floor,
      description: department.description
    })
    
    // 跳转到地图并显示该科室
    navigateToDepartment(`dept_${department.id}`)
  }
  
  return (
    <Card>
      <CardHeader>
        <CardTitle>{department.name}</CardTitle>
      </CardHeader>
      <CardContent>
        <Button onClick={handleViewOnMap}>
          <IconMap className="w-4 h-4 mr-2" />
          在地图上查看
        </Button>
      </CardContent>
    </Card>
  )
}
*/